﻿using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;


namespace AnyOffice.general.system.attend
{
    public partial class attend_manager : ModulePage 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                AttendParaDao dao = new AttendParaDao();
                dao.GetPara();
                string attendManager = dao.AttendManager;
                attendManager = "," + attendManager + ",";
                DataTable table = new UsersDao().SelectBaseAll(base.Conn);
                if (table.Rows.Count > 0)
                {
                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        ListItem item = new ListItem("[" + table.Rows[i]["DeptName"].ToString() + "] " + table.Rows[i]["UserName"].ToString(), table.Rows[i]["UserId"].ToString());
                        if (attendManager.IndexOf("," + table.Rows[i]["UserId"].ToString() + ",") >= 0)
                        {
                            this.pklAttendManager.ItemsLeft.Add(item);
                        }
                        else
                        {
                            this.pklAttendManager.ItemsRight.Add(item);
                        }
                    }
                }
            }
            if (this.Page.IsPostBack)
            {
                this.pnlMain.Visible = false;
                string str2 = "";
                foreach (ListItem item2 in this.pklAttendManager.ItemsLeft)
                {
                    str2 = str2 + item2.Value + ",";
                }
                AttendParaDao dao3 = new AttendParaDao();
                dao3.AttendManager = str2;
                dao3.SetAttendManager(base.Conn);
                base.CloseConn();
                Response.Redirect("index.aspx");
            }
        } 

    }
}
